﻿Public Class FormMesWorkReportList
    Dim objGtPgdMesWorkReport As New clsGtPgdMesWorkReport
    Dim txt As TextBox
    Private Sub FormMesWorkReportList_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim startDate As String = Date.Now.ToShortDateString()
        txtStartDate.Text = startDate
        Dim endDate As String = Date.Now.ToShortDateString()
        txtEndDate.Text = endDate
        setDgvData()
    End Sub
    Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
        setDgvData()
    End Sub

    Private Sub setDgvData()
        If String.IsNullOrEmpty(txtStartDate.Text.Trim()) = False And String.IsNullOrEmpty(txtEndDate.Text.Trim()) = False Then
            Dim dt As DataTable = objGtPgdMesWorkReport.getList(txtStartDate.Text & " 00:00:00.000", txtEndDate.Text & " 23:59:59.999")
            If dt.Rows.Count > 0 Then
                dt.Columns.Add("oper_type_name")
                'dt.Columns.Add("validity_name")
                For Each row As DataRow In dt.Rows
                    If row("oper_type") = "0" Then
                        row("oper_type_name") = "骨架板"
                    Else
                        row("oper_type_name") = "法兰板"
                    End If
                    'If row("validity") = "0" Then
                    '    row("validity_name") = "无效"
                    'Else
                    '    row("validity_name") = "有效"
                    'End If
                Next
            End If
            dgv.AutoGenerateColumns = False
            dgv.DataSource = dt
        Else
            MsgBox("请选择开始时间和结束时间", MsgBoxStyle.Information, "提示")
        End If
    End Sub

    Private Sub txt_MouseClick(sender As Object, e As MouseEventArgs) Handles txtStartDate.MouseClick, txtEndDate.MouseClick
        txt = CType(sender, TextBox)
        DateNavigator1.Left = txt.Left
        DateNavigator1.Top = txt.Location.Y + txt.Height
        DateNavigator1.Visible = True
    End Sub


    Private Sub DateNavigator1_DateTimeChanged(sender As Object, e As EventArgs) Handles DateNavigator1.DateTimeChanged
        txt.Text = DateNavigator1.DateTime.ToShortDateString()
        DateNavigator1.Visible = False
    End Sub

End Class